# encoding: utf-8

class Filter < ActiveRecord::Base
  belongs_to :car_brand
  belongs_to :car_model
  belongs_to :engine_type
  belongs_to :gearbox_type
  belongs_to :parts_group
  
  def parts_group_name
    if parts_group.nil?
      "Any"
    else
      parts_group.name
    end    
  end
  
  def car_brand_name
    if car_brand.nil?
      "Any"
    else
      car_brand.name
    end
  end
  
  def car_model_name
    if car_model.nil?
      "Any"
    else
      car_model.name
    end
  end  
  
  def engine_type_name
    if engine_type.nil?
      "Any"
    else
      engine_type.name
    end
  end  
  
  def gearbox_type_name
    if gearbox_type.nil?
      "Any"
    else
      gearbox_type.name
    end
  end   
  
  def start_year_name
    if start_year.nil?
      "-"
    else
      start_year.to_s
    end
  end   
  
  def end_year_name
    if end_year.nil?
      "-"
    else
      end_year.to_s
    end
  end     
end
